import java.io.Serializable;

public class Score implements Serializable {
    private Student student;
    private Course course;
    private double score;

    public Score(Student student, Course course, double score) throws ScoreRangeException {
        if (score < 0 || score > 100) {
            throw new ScoreRangeException("分数必须在0-100之间，请重新输入！");
        }
        this.student = student;
        this.course = course;
        this.score = score;
    }

    public Student getStudent() {
        return student;
    }

    public Course getCourse() {
        return course;
    }

    public double getScore() {
        return score;
    }

    @Override
    public String toString() {
        return student.getName() + "《" + course.getCourseName() + "》成绩：" + score;
    }
}